/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package PasswrdChk02.Componentes;

import InterfacesPasswordChecker02.ConsectivesFactory;

/**
 *
 * @author LABCCET
 */
public class Consecutivos implements ConsectivesFactory{
    char[] password;
    int passwordLength;
    
  public Consecutivos(String password) {
        this.password = password.toCharArray();
        this.passwordLength = this.passwordLength;
    }
 
  @Override
  public int SomarMinusculasConsecutivas(){
        int count = 0;
        int total = 0;
        for (int i=0; i<this.passwordLength; i++){
            while( i<this.passwordLength && Character.isLowerCase(this.password[i]) ){
                i++;
               count++; 
            }
            if(count>1){
                total+=(count-1);
            }
            count=0;
        }
        return total;
    }
    
  @Override
  public int SomarMaiusculasConsecutivas(){
       int count =0;
        int total=0;
        for (int i=0; i<this.passwordLength;i++){
                    while(i<this.passwordLength && Character.isUpperCase(this.password[i])){
                        i++;
                       count++; 
                    }
                    if(count>1){
                        total+=(count-1);
                    }
                    count=0;
                }
        return total;
    }
    
  @Override
  public int SomarSimbolosConsecutivos(){
        Simbolos simbolos = new Simbolos();
        int count =0;
        int total=0;
        
        for (int i=0; i<this.passwordLength;i++){
                    while(i<this.passwordLength && simbolos.isSimbol(this.password[i])){
                        i++;
                       count++; 
                    }
                    if(count>1){
                        total+=(count-1);
                    }
                    count=0;
                }
        return total;
    }
       
  @Override
  public int SomarDigitosConsecutivos(){
        int count =0;
        int total=0;
        for (int i=0; i<this.passwordLength;i++){
                    while(i<this.passwordLength && Character.isDigit(this.password[i])){
                        i++;
                       count++; 
                    }
                    if(count>1){
                        total+=(count-1);
                     }
                    count=0;
                }
        return total;
    }
}
